package com.laymi.common._util;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.kit.JMap;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xiaoleilu.hutool.util.CollectionUtil;
import com.xiaoleilu.hutool.util.StrUtil;

public class XKit {
	public static Boolean strX(String str, String testStr){
		return StrUtil.containsIgnoreCase( str, testStr);
	}
	public static String[] strs(String str){
		return StrUtil.split(str, ",");
	}
	//查询数据字典
	public static List<String> getD(String table,String code,String text,String extend){
		List<String> l = new ArrayList<String>();
				List<Record> ls = Db.find(Db.getSqlPara("fD", 
							Kv.by("table", table)
							.set("text",text)
							.set("code",code)
							.set("extend",extend)));
		for (Record record : ls) {
			l.add(record.getStr(code)+","+record.getStr(text));
		}
		return l;
	}
	public static String getFirst(String s){
		return s.split(",")[0];
	}
	public static String getLast(String s){//emptyToNull(String str)
		return s.split(",")[1];
	}
	public static boolean isNotBlank(Object str){
		return StrUtil.isNotBlank(str.toString());
	}
	public static String suffix(String str){
		return StrUtil.trim(str.substring(str.lastIndexOf(".")));
	}
}
